//
//  LFGuideViewController.m
//  QingDaoCommunity
//
//  Created by 李学林 on 15/11/22.
//  Copyright © 2015年 teteTechnology. All rights reserved.
//

#import "LFGuideViewController.h"

#import "AppDelegate.h"
#import "LFFunction.h"

@interface LFGuideViewController ()

@end

@implementation LFGuideViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    UIScrollView *scrolView = [[UIScrollView alloc]initWithFrame:kScreemBounds];
    
    scrolView.contentSize = CGSizeMake(3*kScreemWidth, 0);
    
    scrolView.pagingEnabled = YES;
    
    scrolView.showsHorizontalScrollIndicator = NO;
    
    scrolView.bounces =NO;
    [self.view addSubview:scrolView];

    for (int i = 0; i < 3; i++) {
        
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(i*kScreemWidth,0, kScreemWidth, kScreemHeight)];
        
        imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"guide_%d",i]];
        
        [scrolView addSubview:imageView];
        
        //给图片的第三个页面添加手势
        
        if (i == 2) {
            
            UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(enter)];
        
            imageView.userInteractionEnabled = YES;
            
            [imageView addGestureRecognizer:tap];
            
        }
       
    }

}

#pragma mark ========手势

- (void)enter{

    //更改根控制器
//    [[NSUserDefaults standardUserDefaults]setBool:YES forKey:kGuideLaunch];

    [LFFunction setValue:YES forKey:kGuideLaunch];
    
    //第一种方法Appdelegate----不建议使用(在不重要的控制器中调用重要控制器的方法)
    
//    AppDelegate *app = [UIApplication sharedApplication].delegate;
//    
//    [app enterMain];
    
    // 第二种方法:通知
    
    [[NSNotificationCenter defaultCenter] postNotificationName:kNoticeficationGuide object:nil]; 

    
    
    
}

@end
